package leetcode.list;

import java.util.Stack;

/**
 * @author mazouri
 * @create 2021-08-18 23:53
 */
public class _234_isPalindrome {
    public boolean isPalindrome(ListNode head) {
        Stack<ListNode> stack = new Stack<>();
        ListNode cur = head;
        while (cur!=null){
            stack.push(cur);
            cur = cur.next;
        }

        while (head!=null){
            if (head.val != stack.pop().val){
                return false;
            }
            head = head.next;
        }

        return true;
    }
}
